/**
 * Created by bing on 2019/4/4.
 */
package com.wxb.hello.generic.type;

/**
 * describe:
 *
 * @author : wxbing000@gmail.com
 * @version : v1.0
 * @date : 2019-04-04 17:49
 */
public class GenericTypeScope {

	public static void main(String[] args) {
		Plate<? extends Fruit> p = new Plate<Apple>(new Apple());

		//不能存入任何元素
		//p.set(new Fruit());    //Error

		//读取出来的东西只能存放在Fruit或它的基类里。
		Fruit newFruit1 = p.get();
		System.out.println(newFruit1);

	}

}


//Lev 1
class Food {
}

//Lev 2
class Fruit extends Food {
}

class Meat extends Food {
}

//Lev 3
class Apple extends Fruit {
}

class Banana extends Fruit {
}

class Pork extends Meat {
}

class Beef extends Meat {
}

//Lev 4
class RedApple extends Apple {
}

class GreenApple extends Apple {
}


class Plate<T> {
	private T item;

	public Plate(T t) {
		item = t;
	}

	public void set(T t) {
		item = t;
	}

	public T get() {
		return item;
	}
}


